package com.avic.system.service.impl;

import com.avic.system.dal.condition.FindSystemLogListCondition;
import com.avic.system.dal.model.SystemLog;
import com.avic.system.service.SystemLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author huangsheng on 2018/12/10
 */
@Service
@Slf4j
public class SystemLogServiceImpl extends SystemAbstractServiceImpl implements SystemLogService {


    @Override
    public List<SystemLog> systemLogList(FindSystemLogListCondition findSystemLogListCondition) {
        return systemLogMapper.systemLogList(findSystemLogListCondition);
    }

    @Override
    public int logListTotalCount(FindSystemLogListCondition findSystemLogListCondition) {
        return systemLogMapper.logListTotalCount(findSystemLogListCondition);
    }

    @Override
    public int createSystemLog(String logDetail, String userId) {
        try {
            SystemLog systemLog = new SystemLog(userId, logDetail);

            systemLogMapper.insertSystemLog(systemLog);
            log.info("成功新增 {} 的系统日志", systemLog);
            return systemLog.getId();
        } catch (Exception e) {
            log.error("新增系统日志时发生错误{}", e.getMessage());
        }
        return 0;
    }
}
